[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Constants                Define Constants                     Program Section

    Standard Pascal allows you to define constants in your program or
    subprogram. A constant is NOT a pre-initialized variable. It is just a
    name that can be used in place of the corresponding value. Constants
    cannot be passed as VAR parameters, nor can they be assigned values.
    They can be used to delimit subranges (types, array indices, sets) and
    also be used in CASE statements.

    Constants are declared in the declaration section of the program or
    subprogram. A list of constants is preceded by the word CONST and uses
    the following syntax:

         const
           <cname>   = <cvalue>;
           <cname>   = <cvalue>;
           { etc. }

    where <cname> is any legal identifier and <cvalue> is a literal value
    of type Integer, Real, Char, Boolean, or string.

    In Standard Pascal, you can have only one CONST section in a program
    (or subprogram), and it must come after the LABEL section and before
    the TYPE section. In Turbo Pascal, you can have as many CONST sections
    as you want, and there are no ordering restrictions.

  -------------------------------- Example ---------------------------------

           const
              Limit     = 100;
              Yes       = True;
              Bell      = ^G;       { = Ctrl-G }
              e         = 2.7182818285;
              FileName  = 'C:\MYSTUFF.TXT';

See Also: const types variables typed constants
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson